package cn.zhaiyy.springboot.controller;

import cn.zhaiyy.springboot.config.MyConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class ConfigController {

    @Value("${server.port}")
    private String port;

    @Value("${desc}")
    private String desc;

    @Value("${random.value}")
    private String randomString;

    @Value("${random.int}")
    private int randomInt;

    @Value("${random.long}")
    private long randomLong;

    @Value("${random.int10}")
    private int randomInt10;

    @Value("${randomInt10_20}")
    private String randomInt10_20;

    @Value("${config.username}")
    private String username;

    @Autowired
    private MyConfig config;

    @RequestMapping("config/all")
    public ResponseEntity<List> getConfig() {
        List<Object> list = new ArrayList<>();
        list.add(port);
        list.add(desc);
        list.add(randomString);
        list.add(randomInt);
        list.add(randomInt10);
        list.add(randomInt10_20);
        list.add(randomLong);
        list.add(username);
        list.add(config);
        return ResponseEntity.ok(list);
    }
}
